package com.wlzg.collectiontool.db

import android.util.Log
import androidx.room.TypeConverter
import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
import com.wlzg.collectiontool.model.bean.Hunjie
import com.wlzg.collectiontool.model.bean.PsHunjie
import java.util.*

 class HunjieConvert {
    @TypeConverter
    fun revert(jsonString: String): List<PsHunjie>? {
        Log.d("TSTST","ccsd"+jsonString)
        try {
            val type =
                object : TypeToken<List<PsHunjie?>?>() {}.type
            return Gson().fromJson(jsonString, type)
        } catch (e: Exception) {
            e.printStackTrace()
        }
        return null
    }

    @TypeConverter
    fun converter(list: List<PsHunjie?>?): String {
        Log.d("TSTST","dcc"+Gson().toJson(list))
        return Gson().toJson(list)
    }
}